<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>手机号正则表达式</title>
    <script>
        //手机号规则：
        //  1.以1开头
        //  2.第二位任意数字
        //  3.三位以后任意数字九个
        var phone = "11296642923";
        var phoneReg = /^1[3-9][0-9]{9}$/;
        console.log(phoneReg.test(phone));
        var str = prompt("请输入用户名:");
        console.log(str);
        //自动去除字符串前后空格
        str =str.replace(/^\s*|\s*$/g,"");
        console.log(str);
    </script>
</head>
<body>
    
</body>
</html>